//
//  FDContentView.m
//  FamousDoctorOnline
//
//  Created by wszyxc on 16/7/5.
//  Copyright © 2016年 wszyxc. All rights reserved.
//

#import "FDContentView.h"

@implementation FDContentView

- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    //设置子控件的frame
    
    //添加6个小视图,小视图上面有一个button和一个label
    NSInteger col = 3;
    NSInteger row = 2;
    CGFloat margin = 1;
    CGFloat viewWidth = (SCREEN_WIDTH - (col + 1)*margin)/col;
    
//    NSLog(@"内容高度  %f",CGRectGetHeight(self.contentView.bounds));
    CGFloat viewHeight = (CGRectGetHeight(self.bounds) - row *margin)/2;
    
//    NSLog(@"width= %f,height = %f",viewWidth,viewHeight);
    NSInteger index = 0;
  
    for (UIView *smallView in self.subviews){
        
        NSInteger colIndex = index%col;
        NSInteger rowIndex = index/col;
        
        CGFloat viewX = colIndex *(margin + viewWidth) + margin;
        CGFloat viewY = rowIndex *(margin + viewHeight) + margin;
        
        smallView.frame = CGRectMake(viewX, viewY, viewWidth, viewHeight);
        
        index++;
        
    }

    
}


@end
